package org.shan.hangtian.server.handler;

import com.mlnx.common.utils.MyLog;

import org.shan.hangtian.tp.HangtianPacket;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;


public class DataEncode extends MessageToByteEncoder<HangtianPacket> {

	MyLog log = MyLog.getLog(getClass());

	@Override
	protected void encode(ChannelHandlerContext arg0, HangtianPacket arg1,
                          ByteBuf arg2) throws Exception {

		try {
			byte[] bs = arg1.encode();
			arg2.writeBytes(bs);
		}catch (Exception e){
			log.error(e, "发送数据包错误");
		}
	}

}
